package gqlgencs

import (
	"gitee.com/lailonghui/vehicle-supervision-framework/pkg/services"
	"gitee.com/shiqiyue/gqlgenc/clientv2"
	"net/http"
)

// 通过配置新建客户端
func NewClientByConfig(config *services.EndpointConfig) *http.Client {
	c := http.Client{}
	if config == nil {
		return &c
	}
	if config.Timeout != nil {
		c.Timeout = *config.Timeout
	}

	return &c
}

// 通过配置创建interceptor
func NewInterceptorsByConfig(config *services.EndpointConfig) (ints []clientv2.RequestInterceptor) {

	ints = append(ints, AuthorizationInterceptor())
	ints = append(ints, OpenTracingInterceptor())
	return
}
